#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
int main()
{
	int arr[100];
	memset(arr,0,sizeof(int)*100);
	int cnt = 0;
	int i = 0;
	int N = 0, M = 0;
	int k = 0;
	scanf("%d",&N);
	scanf("%d",&M);
	while (N != cnt)
	{
		i++;
		if (i > N)
		{
			i = 1;
		}
		if (arr[i] == 0)
		{
			k++;
			if (k == M)
			{
				arr[i] = 1;
				cnt++;
				printf("%d", i);
				k = 0;
			}
		}
	}
	return 0;
}